const { addGoods, findAll } = require("../service/cart.service");

class Cart {
  async add(ctx, next) {
    let res = await addGoods(ctx.state.user.id, ctx.request.body.goods_id);
    console.log(res, "res");
    ctx.body = {
      code: "0",
      msg: "成功",
      res,
    };
  }
  async getlist(ctx) {
    let res = await findAll(ctx.request.query.page, ctx.request.query.pagesize);
    ctx.body = {
      code: 0,
      msg: "获取购物车成功",
      res,
    };
  }
}

module.exports = new Cart();
